package com.retailcloud.inventoryservice.controller;

import java.util.Arrays;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.retailcloud.inventoryservice.entity.ProductInventoryEntity;
import com.retailcloud.inventoryservice.service.ProductInventoryService;
import com.retailcloud.commonutils.utils.PageUtils;
import com.retailcloud.commonutils.utils.R;



/**
 * 商品库存表
 *
 * @author wudi
 * @email 632132852@qq.com
 * @date 2024-11-05 21:41:03
 */
@RestController
@RequestMapping("/productinventory")
public class ProductInventoryController {
    @Autowired
    private ProductInventoryService productInventoryService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions(":productinventory:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = productInventoryService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    //@RequiresPermissions(":productinventory:info")
    public R info(@PathVariable("id") String id){
		ProductInventoryEntity productInventory = productInventoryService.getById(id);

        return R.ok().put("productInventory", productInventory);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions(":productinventory:save")
    public R save(@RequestBody ProductInventoryEntity productInventory){
		productInventoryService.save(productInventory);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions(":productinventory:update")
    public R update(@RequestBody ProductInventoryEntity productInventory){
		productInventoryService.updateById(productInventory);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions(":productinventory:delete")
    public R delete(@RequestBody String[] ids){
		productInventoryService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
